package org.ajax.controller;

import com.alibaba.fastjson.JSON;
import org.ajax.pojo.User;

public class FastJsonDemo1 {
    public static void main(String[] args) {
        //java转json
        User user = new User();
        user.setId(12);
        user.setUsername("root");
        user.setPassword("123456");
        String s = JSON.toJSONString(user);
        System.out.println(s);
        //json转java
        User user1 = JSON.parseObject("{\"password\":\"123456\",\"id\":12,\"username\":\"root\"}", User.class);
        System.out.println(user1);
        System.out.println(user.toString());
        System.out.println(System.getProperty("user.dir"));
//        {"id":12,"password":"123456","username":"root"}
//        User{id=12, username='root', password='123456'}
    }
}
